from django.test import TestCase

# Create your tests here.

import subprocess
# from jiangsqobj.settings import

# sub_obj = subprocess.run(['df','-h'],stderr=subprocess.PIPE,stdout=subprocess.PIPE,check=True)  # check=True 出错时是否抛出异常
# sub_obj = subprocess.run('dir', shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
# print(sub_obj)
# print(sub_obj.stdout.decode(encoding='gbk').encode().decode('utf8'))  # 执行成功时的信息
# print(sub_obj.stderr.decode(encoding='gbk').encode().decode('utf8'))  # 执行失败的信息
# print(sub_obj.returncode)  # 成功或失败的状态


sub_obj = subprocess.Popen('dir',shell=True,cwd=r'D:\python3\jiangsqobj',stderr=subprocess.PIPE, stdout=subprocess.PIPE)
print(sub_obj.returncode)
# print(type(sub_obj.returncode))
print('stderr:',sub_obj.stderr.read().decode(encoding='gbk').encode().decode('utf8'))
print('stdout:',sub_obj.stdout.read().decode(encoding='gbk').encode().decode('utf8'))
print(sub_obj.pid)

# b''.decode(encoding='utf8').encode().decode('utf8')
import datetime

# a = {'_tzinfos': {(datetime.timedelta(0, 29160), datetime.timedelta(0), 'LMT'): <DstTzInfo 'Asia/Shanghai' LMT+8:06:00 STD>, (datetime.timedelta(0, 28800), datetime.timedelta(0), 'CST'): <DstTzInfo 'Asia/Shanghai' CST+8:00:00 STD>, (datetime.timedelta(0, 32400), datetime.timedelta(0, 3600), 'CDT'): <DstTzInfo 'Asia/Shanghai' CDT+9:00:00 DST>}, '_utcoffset': datetime.timedelta(0, 29160), '_dst': datetime.timedelta(0), '_tzname': 'LMT'}
